package com.democxy.front;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.validator.constraints.Length;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.democxy.common.baseData.ResponeData;
import com.democxy.common.enums.ResultEnum;
import com.democxy.modules.cms.api.ArticleService;
import com.democxy.modules.cms.entity.AdHref;
import com.democxy.modules.cms.entity.AppSetInfo;
import com.democxy.modules.cms.entity.BlogType;
import com.democxy.modules.cms.entity.Blogs;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service("blogs")
public class BlogService {
	
	@Autowired
	private ArticleService articleService;
	
	/**
	 * 获取博客信息
	 * @param pageSize 获取条数
	 * @param orderBy 排序
	 * @return
	 */
	public List<Blogs> getBlogs(Integer pageSize,String orderBy){
		List<Blogs> list = new ArrayList<Blogs>();
		ResponeData<List<Blogs>> blogs = this.articleService.getBlogs(pageSize, orderBy);
		
		if (blogs.getCode() == 500) {
			//异常
			list = null;
		}else {
			list = blogs.getData();
		}
		return list;
	}
	
	/**
	 * 获取博客类型
	 * @return
	 */
	public List<BlogType> geTypes(){
		List<BlogType> list = new ArrayList<BlogType>();
		
		ResponeData<PageInfo<BlogType>> adList = this.articleService.typeList(new BlogType());
		
		if (adList.getCode() == 500) {
			//异常
			list = null;
		}else {
			list = adList.getData().getList();
		}		
		
		

		return list;
	}
	
	
}

